home *** CD-ROM | disk | FTP | other *** search
/ STraTOS 1997 April & May / STraTOS 1 - 1997 April & May.iso / CD01 / INTERNET / SITES / LITTLE / P3SRC.ZIP / ATARI / OPTOUT.C < prev    next >
Encoding:
C/C++ Source or Header  |  1997-01-21  |  42.1 KB  |  1,560 lines

  1. /****************************************************************************
  2. *                   optout.c
  3. *
  4. *  This module contains functions for credit, usage, options and stats.
  5. *
  6. *  from Persistence of Vision(tm) Ray Tracer
  7. *  Copyright 1996 Persistence of Vision Team
  8. *---------------------------------------------------------------------------
  9. *  NOTICE: This source code file is provided so that users may experiment
  10. *  with enhancements to POV-Ray and to port the software to platforms other
  11. *  than those supported by the POV-Ray Team.  There are strict rules under
  12. *  which you are permitted to use this file.  The rules are in the file
  13. *  named POVLEGAL.DOC which should be distributed with this file. If
  14. *  POVLEGAL.DOC is not available or for more info please contact the POV-Ray
  15. *  Team Coordinator by leaving a message in CompuServe's Graphics Developer's
  16. *  Forum.  The latest version of POV-Ray may be found there as well.
  17. *
  18. * This program is based on the popular DKB raytracer version 2.12.
  19. * DKBTrace was originally written by David K. Buck.
  20. * DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins.
  21. *
  22. *****************************************************************************/
  23.  
  24. #include <ctype.h>
  25. #include <time.h>
  26. #include "frame.h"
  27. #include "vector.h"
  28. #include "povproto.h"
  29. #include "atmosph.h"
  30. #include "bezier.h"
  31. #include "blob.h"
  32. #include "bbox.h"
  33. #include "cones.h"
  34. #include "csg.h"
  35. #include "discs.h"
  36. #include "fractal.h"
  37. #include "hfield.h"
  38. #include "lathe.h"
  39. #include "lighting.h"
  40. #include "mesh.h"
  41. #include "polysolv.h"
  42. #include "objects.h"
  43. #include "parse.h"
  44. #include "point.h"
  45. #include "poly.h"
  46. #include "polygon.h"
  47. #include "octree.h"
  48. #include "quadrics.h"
  49. #include "pgm.h"
  50. #include "ppm.h"
  51. #include "prism.h"
  52. #include "radiosit.h"
  53. #include "render.h"
  54. #include "sor.h"
  55. #include "spheres.h"
  56. #include "super.h"
  57. #include "targa.h"
  58. #include "texture.h"
  59. #include "torus.h"
  60. #include "triangle.h"
  61. #include "truetype.h"
  62. #include "userio.h"
  63. #include "lbuffer.h"
  64. #include "vbuffer.h"
  65. #include "povray.h"
  66. #include "optin.h"
  67. #include "optout.h"
  68.  
  69.  
  70.  
  71. /*****************************************************************************
  72. * Local preprocessor defines
  73. ******************************************************************************/
  74.  
  75. #define NUMBER_LENGTH 19
  76. #define OUTPUT_LENGTH 15
  77.  
  78. #define NUMBER_OF_AUTHORS_ACROSS  4
  79.  
  80.  
  81. /*****************************************************************************
  82. * Local typedefs
  83. ******************************************************************************/
  84.  
  85.  
  86.  
  87. /*****************************************************************************
  88. * Local variables
  89. ******************************************************************************/
  90.  
  91. static char numbers[64][20] =
  92. {
  93. "0000000000000000001",
  94. "0000000000000000002",
  95. "0000000000000000004",
  96. "0000000000000000008",
  97. "0000000000000000016",
  98. "0000000000000000032",
  99. "0000000000000000064",
  100. "0000000000000000128",
  101. "0000000000000000256",
  102. "0000000000000000512",
  103. "0000000000000001024",
  104. "0000000000000002048",
  105. "0000000000000004096",
  106. "0000000000000008192",
  107. "0000000000000016384",
  108. "0000000000000032768",
  109. "0000000000000065536",
  110. "0000000000000131072",
  111. "0000000000000262144",
  112. "0000000000000524288",
  113. "0000000000001048576",
  114. "0000000000002097152",
  115. "0000000000004194304",
  116. "0000000000008388608",
  117. "0000000000016777216",
  118. "0000000000033554432",
  119. "0000000000067108864",
  120. "0000000000134217728",
  121. "0000000000268435456",
  122. "0000000000536870912",
  123. "0000000001073741824",
  124. "0000000002147483648",
  125. "0000000004294967296",
  126. "0000000008589934592",
  127. "0000000017179869184",
  128. "0000000034359738368",
  129. "0000000068719476736",
  130. "0000000137438953472",
  131. "0000000274877906944",
  132. "0000000549755813888",
  133. "0000001099511627776",
  134. "0000002199023255552",
  135. "0000004398046511104",
  136. "0000008796093022208",
  137. "0000017592186044416",
  138. "0000035184372088832",
  139. "0000070368744177664",
  140. "0000140737488355328",
  141. "0000281474976710656",
  142. "0000562949953421312",
  143. "0001125899906842624",
  144. "0002251799813685248",
  145. "0004503599627370496",
  146. "0009007199254740992",
  147. "0018014398509481984",
  148. "0036028797018963968",
  149. "0072057594037927936",
  150. "0144115188075855872",
  151. "0288230376151711744",
  152. "0576460752303423488",
  153. "1152921504606846976",
  154. "2305843009213693952",
  155. "4611686018427387904",
  156. "9223372036854775808"
  157. };
  158.  
  159. static char s1[OUTPUT_LENGTH], s2[OUTPUT_LENGTH];
  160.  
  161. char *Primary_Developers[] =
  162. {
  163.   "Steve Anger",
  164.   "Dieter Bayer",
  165.   "Chris Cason",
  166.   "Chris Dailey",
  167.   "Andreas Dilger",
  168.   "Steve Demlow",
  169.   "Alexander Enzmann",
  170.   "Dan Farmer",
  171.   "Timothy Wegner",
  172.   "Chris Young",
  173.   NULL   /* NULL flags the end of the list */
  174. };
  175.  
  176. char *Contributing_Authors[] =
  177. {
  178.   "Steve A. Bennett",
  179.   "David K. Buck",
  180.   "Aaron A. Collins",
  181.   "Pascal Massimino",
  182.   "Jim McElhiney",
  183.   "Douglas Muir",
  184.   "Bill Pulver",
  185.   "Robert Skinner",
  186.   "Zsolt Szalavari",
  187.   "Scott Taylor",
  188.   "Drew Wells",
  189.   NULL   /* NULL flags the end of the list */
  190. };
  191.  
  192.  
  193. /*****************************************************************************
  194. * Static functions
  195. ******************************************************************************/
  196.  
  197. static void rinfo_on PARAMS((char *string, unsigned value));
  198. static void add_numbers PARAMS((char *result, char *c1, char *c2));
  199. static void counter_to_string PARAMS((COUNTER *counter, char *string, int len));
  200. static void print_intersection_stats PARAMS((char *text, COUNTER *tests, COUNTER *succeeded));
  201.  
  202.  
  203.  
  204. /*****************************************************************************
  205. *
  206. * FUNCTION
  207. *
  208. *   add_numbers
  209. *
  210. * INPUT
  211. *   
  212. * OUTPUT
  213. *   
  214. * RETURNS
  215. *   
  216. * AUTHOR
  217. *
  218. *   Dieter Bayer
  219. *   
  220. * DESCRIPTION
  221. *
  222. *   Add two decimal numbers stored in ASCII strings.
  223. *
  224. * CHANGES
  225. *
  226. *   Mar 1995 : Creation
  227. *
  228. ******************************************************************************/
  229.  
  230. static void add_numbers(result, c1, c2)
  231. char *result, *c1, *c2;
  232. {
  233.   int i;
  234.   char carry, x;
  235.  
  236.   carry = '0';
  237.  
  238.   for (i = NUMBER_LENGTH-1; i >= 0; i--)
  239.   {
  240.     x = c1[i] + c2[i] + carry - '0' - '0';
  241.  
  242.     if (x > '9')
  243.     {
  244.       carry = '1';
  245.  
  246.       result[i] = x - 10;
  247.     }
  248.     else
  249.     {
  250.       carry = '0';
  251.  
  252.       result[i] = x;
  253.     }
  254.   }
  255. }
  256.  
  257.  
  258.  
  259. /*****************************************************************************
  260. *
  261. * FUNCTION
  262. *
  263. *   counter_to_string
  264. *
  265. * INPUT
  266. *   
  267. * OUTPUT
  268. *   
  269. * RETURNS
  270. *   
  271. * AUTHOR
  272. *
  273. *   Dieter Bayer
  274. *   
  275. * DESCRIPTION
  276. *
  277. *   Convert a low/high precision counter into a decimal number.
  278. *
  279. * CHANGES
  280. *
  281. *   Mar 1995 : Creation
  282. *
  283. ******************************************************************************/
  284.  
  285. static void counter_to_string(counter, string, len)
  286. COUNTER *counter;
  287. char *string;
  288. int len;
  289. {
  290.   char n[NUMBER_LENGTH+1];
  291.   int i, j;
  292.   COUNTER c;
  293.  
  294.   c = *counter;
  295.  
  296.   for (i = 0; i < NUMBER_LENGTH; i++)
  297.   {
  298.     n[i] = '0';
  299.   }
  300.  
  301.   n[NUMBER_LENGTH] = '\0';
  302.  
  303. #if COUNTER_RESOLUTION == HIGH_RESOLUTION
  304.  
  305.   for (i = 0; i < 32; i++)
  306.   {
  307.     if (c.low & 1)
  308.     {
  309.       add_numbers(n, n, numbers[i]);
  310.     }
  311.  
  312.     c.low >>= 1;
  313.   }
  314.  
  315.   for (i = 32; i < 64; i++)
  316.   {
  317.     if (c.high & 1)
  318.     {
  319.       add_numbers(n, n, numbers[i]);
  320.     }
  321.  
  322.     c.high >>= 1;
  323.   }
  324.  
  325. #else
  326.  
  327.   for (i = 0; i < 32; i++)
  328.   {
  329.     if (c & 1)
  330.     {
  331.       add_numbers(n, n, numbers[i]);
  332.     }
  333.  
  334.     c >>= 1;
  335.   }
  336.  
  337. #endif
  338.  
  339.   /* Replace leading zeros. */
  340.  
  341.   for (i = 0; i < NUMBER_LENGTH-1; i++)
  342.   {
  343.     if (n[i] == '0')
  344.     {
  345.       n[i] = ' ';
  346.     }
  347.     else
  348.     {
  349.       break;
  350.     }
  351.   }
  352.  
  353.   /* Copy number into result string. */
  354.  
  355.   if (i >= NUMBER_LENGTH-len)
  356.   {
  357.     for (j = 0; j < i-NUMBER_LENGTH+len-1; j++)
  358.     {
  359.       string[j] = ' ';
  360.     }
  361.  
  362.     string[j] = '\0';
  363.  
  364.     string = strcat(string, &n[i]);
  365.   }
  366.   else
  367.   {
  368.     /* Print numbers that don't fit into output string in million units. */
  369.  
  370.     string = "";
  371.  
  372.     n[NUMBER_LENGTH-6] = 'm';
  373.     n[NUMBER_LENGTH-5] = '\0';
  374.  
  375.     string = strcat(string, &n[NUMBER_LENGTH-len+1-6]);
  376.   }
  377. }
  378.  
  379.  
  380.  
  381. /*****************************************************************************
  382. *
  383. * FUNCTION
  384. *
  385. *   print_intersections_stats
  386. *
  387. * INPUT
  388. *   
  389. * OUTPUT
  390. *   
  391. * RETURNS
  392. *   
  393. * AUTHOR
  394. *
  395. *   Dieter Bayer
  396. *   
  397. * DESCRIPTION
  398. *
  399. *   -
  400. *
  401. * CHANGES
  402. *
  403. *   Mar 1995 : Creation
  404. *
  405. ******************************************************************************/
  406.  
  407. static void print_intersection_stats(text, tests, succeeded)
  408. char *text;
  409. COUNTER *tests, *succeeded;
  410. {
  411.   DBL t, s, p;
  412.  
  413.   if (!Test_Zero_Counter(*tests))
  414.   {
  415.     t = DBL_Counter(*tests);
  416.     s = DBL_Counter(*succeeded);
  417.  
  418.     p = 100.0 * s / t;
  419.  
  420.     counter_to_string(tests, s1, OUTPUT_LENGTH);
  421.     counter_to_string(succeeded, s2, OUTPUT_LENGTH);
  422.  
  423.     Statistics("%-22s  %s  %s  %8.2f\n", text, s1, s2, p);
  424.   }
  425. }
  426.  
  427.  
  428.  
  429. /*****************************************************************************
  430. *
  431. * FUNCTION
  432. *
  433. *   rinfo_on
  434. *
  435. * INPUT
  436. *
  437. * OUTPUT
  438. *
  439. * RETURNS
  440. *
  441. * AUTHOR
  442. *
  443. *   POV-Ray Team
  444. *
  445. * DESCRIPTION
  446. *
  447. *   -
  448. *
  449. * CHANGES
  450. *
  451. *   -
  452. *
  453. ******************************************************************************/
  454.  
  455. static void rinfo_on(string, value)
  456. char *string;
  457. unsigned value;
  458. {
  459.   if (value)
  460.   {
  461.     Render_Info("%s.On",(string));
  462.   }
  463.   else
  464.   {
  465.     Render_Info("%sOff",(string));
  466.   }
  467. }
  468.  
  469.  
  470.  
  471. /*****************************************************************************
  472. *
  473. * FUNCTION
  474. *
  475. *   Print_Credits
  476. *
  477. * INPUT
  478. *   
  479. * OUTPUT
  480. *   
  481. * RETURNS
  482. *   
  483. * AUTHOR
  484. *
  485. *   POV-Ray Team
  486. *   
  487. * DESCRIPTION
  488. *
  489. *   -
  490. *
  491. * CHANGES
  492. *
  493. *   -
  494. *
  495. ******************************************************************************/
  496.  
  497. void Print_Credits()
  498. {
  499.   Banner ("Persistence of Vision(tm) Ray Tracer Version %s%s\n", POV_RAY_VERSION, COMPILER_VER);
  500.   Banner ("  %s\n", DISTRIBUTION_MESSAGE_1);
  501.   Banner ("  %s\n", DISTRIBUTION_MESSAGE_2);
  502.   Banner ("  %s\n", DISTRIBUTION_MESSAGE_3);
  503.   Banner ("Copyright 1996 POV-Ray Team(tm)\n");
  504. }
  505.  
  506.  
  507.  
  508. /*****************************************************************************
  509. *
  510. * FUNCTION
  511. *
  512. *   Print_Help_Screens
  513. *
  514. * INPUT
  515. *   
  516. * OUTPUT
  517. *   
  518. * RETURNS
  519. *   
  520. * AUTHOR
  521. *
  522. *   Dieter Bayer
  523. *   
  524. * DESCRIPTION
  525. *
  526. *   Print all help screens. Use an interactive menu if GET_KEY exists.
  527. *
  528. * CHANGES
  529. *
  530. *   Apr 1995 : Creation.
  531. *
  532. ******************************************************************************/
  533.  
  534. void Print_Help_Screens()
  535. {
  536. #ifdef GET_KEY_EXISTS
  537.   char c;
  538.   int n, x, ok;
  539.  
  540.   Usage(-1, FALSE);
  541.  
  542.   for (n = 0; ; )
  543.   {
  544.     Banner("\n");
  545.     Banner("[ Press 0 for general help, 1 to %d for help screen. Press 'q' to quit. ]", MAX_HELP_PAGE);
  546.  
  547.     do
  548.     {
  549.       ok = FALSE;
  550.  
  551.       GET_KEY(x);
  552.  
  553.       c = (char)x;
  554.  
  555.       if ((c >= '0') && (c <= '0' + MAX_HELP_PAGE))
  556.       {
  557.         ok = TRUE;
  558.  
  559.         n = (int)c - (int)'0';
  560.       }
  561.       else
  562.       {
  563.         if ((c == 'q') || (c == 'Q'))
  564.         {
  565.           ok = TRUE;
  566.         }
  567.       }
  568.     }
  569.     while(!ok);
  570.  
  571.     Banner("\n");
  572.  
  573.     if ((c == 'q') || (c == 'Q'))
  574.     {
  575.       break;
  576.     }
  577.  
  578.     Usage(n, FALSE);
  579.   }
  580.  
  581.   Terminate_POV(0);
  582. #else
  583.   int n;
  584.  
  585.   for (n = -1; n <= MAX_HELP_PAGE; n++)
  586.   {
  587.     Usage(n, (n == MAX_HELP_PAGE));
  588.   }
  589. #endif
  590. }
  591.  
  592.  
  593.  
  594. /*****************************************************************************
  595. *
  596. * FUNCTION
  597. *
  598. *   Usage
  599. *
  600. * INPUT
  601. *
  602. *   n - Number of usage screen
  603. *   f - Flag to terminate
  604. *   
  605. * OUTPUT
  606. *   
  607. * RETURNS
  608. *   
  609. * AUTHOR
  610. *
  611. *   POV-Ray Team
  612. *   
  613. * DESCRIPTION
  614. *
  615. *   Print out usage messages.
  616. *
  617. * CHANGES
  618. *
  619. *   Dec 1994 : Changed to show options depending on parameter n. [DB]
  620. *
  621. *   Feb 1995 : Changed to terminate only if f != 0. [DB]
  622. *
  623. ******************************************************************************/
  624.  
  625. void Usage(n, f)
  626. int n, f;
  627. {
  628.   switch (n)
  629.   {
  630.     /* Help screen. */
  631.  
  632.     case 0:
  633.  
  634.       Banner("\n");
  635.       Banner("Usage: POVRAY [+/-]Option1 [+/-]Option2 ... (-h or -? for help)\n");
  636.       Banner("\n");
  637.       Banner("  Example: POVRAY scene.ini +Iscene.pov +Oscene.tga +W320 +H200\n");
  638.       Banner("  Example: POVRAY +Iscene.pov +Oscene.tga +W160 +H200 +V -D +X\n");
  639.       Banner("\n");
  640.       Banner("The help screen is divided into several parts. To access one part\n");
  641.       Banner("just enter the number of the screen after the -h or -? option.\n");
  642.       Banner("\n");
  643.       Banner("E.g. use -h5 to see the help screen about the tracing options.\n");
  644.       Banner("\n");
  645.       Banner("  Number  Part\n");
  646.       Banner("    1     Parsing Options\n");
  647.       Banner("    2     Output Options\n");
  648.       Banner("    3     Output Options - display related\n");
  649.       Banner("    4     Output Options - file related\n");
  650.       Banner("    5     Tracing Options\n");
  651.       Banner("    6     Animation Options\n");
  652.       Banner("    7     Redirecting Options\n");
  653.  
  654.       break;
  655.  
  656.     /* Parsing options. */
  657.  
  658.     case 1:
  659.  
  660.       Banner("\n");
  661.       Banner("Parsing options\n");
  662.       Banner("\n");
  663.       Banner("  I<name> = input file name\n");
  664.       Banner("  L<name> = library path prefix\n");
  665.       Banner("  MVn.n   = set compability to version n.n\n");
  666.       Banner("  SU      = split bounded unions if children are finite\n");
  667.       Banner("  UR      = remove unnecessary bounding objects\n");
  668.  
  669.       break;
  670.  
  671.     /* Output options. */
  672.  
  673.     case 2:
  674.  
  675.       Banner("\n");
  676.       Banner("Output options\n");
  677.       Banner("\n");
  678.       Banner("  Hnnn    = image height\n");
  679.       Banner("  Wnnn    = image width\n");
  680.       Banner("\n");
  681.       Banner("  SRnn    = start at row nn | SR0.nn start row at nn percent of screen\n");
  682.       Banner("  ERnn    = end   at row nn | ER0.nn end   row at nn percent of screen\n");
  683.       Banner("  SCnn    = start at col nn | SC0.nn start col at nn percent of screen\n");
  684.       Banner("  ECnn    = end   at col nn | EC0.nn end   col at nn percent of screen\n");
  685.       Banner("\n");
  686.       Banner("  C       = continue aborted trace\n");
  687.       Banner("  P       = pause before exit\n");
  688.       Banner("  V       = verbose messages on\n");
  689.       Banner("  Xnnn    = enable early exit by key hit (every nnn pixels)\n");
  690.  
  691.       break;
  692.  
  693.     case 3:
  694.  
  695.       Banner("\n");
  696.       Banner("Output options - display related\n");
  697.       Banner("\n");
  698.       Banner("  Dxy     = display in format x, using palette option y\n");
  699.       Banner("  SPnnn   = Mosaic Preview display, Start grid size = 2, 4, 8, 16, ...\n");
  700.       Banner("  EPnnn   = Mosaic Preview display, End grid size   = 2, 4, 8, 16, ...\n");
  701.       Banner("  UD      = draw vista rectangles\n");
  702.  
  703.       break;
  704.  
  705.     /* Output options - file related. */
  706.  
  707.     case 4:
  708.  
  709.       Banner("\n");
  710.       Banner("Output options - file related\n");
  711.       Banner("\n");
  712.       Banner("  Bnnn    = Use nnn KB for output file buffer\n");
  713.       Banner("  Fx      = write output file in format x\n");
  714.       Banner("            FC  - Compressed Targa with 24 or 32 bpp\n");
  715.       Banner("            FNn - PNG (n bits/color, n = 5 to 16, default is 8)\n");
  716.       Banner("            FP  - PPM\n");
  717.       Banner("            FS  - System specific\n");
  718.       Banner("            FT  - Uncompressed Targa with 24 or 32 bpp\n");
  719.       Banner("  O<name> = output file name\n");
  720. #if PRECISION_TIMER_AVAILABLE
  721.       Banner("\n");
  722.       Banner("  HTx     = write CPU utilization histogram in format x\n");
  723.       Banner("            HTC - Comma separated values (CSV - spreadsheet)\n");
  724.       Banner("            HTN - PNG grayscale\n");
  725.       Banner("            HTP - PPM heightfield\n");
  726.       Banner("            HTS - System specific\n");
  727.       Banner("            HTT - Uncompressed TGA heightfield\n");
  728.       Banner("            HTX - No histogram output\n");
  729.       Banner("  HN<name>= histogram filename\n");
  730.       Banner("  HSx.y   = histogram grid number of x, y divisions\n");
  731. #endif
  732.  
  733.       break;
  734.  
  735.     /* Tracing options. */
  736.  
  737.     case 5:
  738.  
  739.       Banner("\n");
  740.       Banner("Tracing options\n");
  741.       Banner("\n");
  742.       Banner("  MBnnn   = use slabs if more than nnn objects\n");
  743.       Banner("  Qn      = image quality (0 = rough, 9 = full, R = radiosity)\n");
  744.       Banner("  QR      = enable radiosity calculations for ambient light\n");
  745.       Banner("\n");
  746.       Banner("  A0.n    = perform antialiasing\n");
  747.       Banner("  AMn     = use non-adaptive (n=1) or adaptive (n=2) supersampling\n");
  748.       Banner("  Jn.n    = set antialiasing-jitter amount\n");
  749.       Banner("  Rn      = set antialiasing-depth (use n X n rays/pixel)\n");
  750.       Banner("\n");
  751.       Banner("  UL      = use light buffer\n");
  752.       Banner("  UV      = use vista buffer\n");
  753.  
  754.       break;
  755.  
  756.     /* Animation options. */
  757.  
  758.     case 6:
  759.  
  760.       Banner("\n");
  761.       Banner("Animation options\n");
  762.       Banner("\n");
  763.       Banner("  Kn.n      = set frame clock to n.n\n");
  764.       Banner("  KFInnn    = Initial frame number\n");
  765.       Banner("  KFFnnn    = Final frame number\n");
  766.       Banner("  KInnn.nn  = Initial clock value\n");
  767.       Banner("  KFnnn.nn  = Final clock value\n");
  768.       Banner("  SFnn      = Start subset at frame nn\n");
  769.       Banner("  SF0.nn    = Start subset nn percent into sequence\n");
  770.       Banner("  EFnn      = End subset at frame nn\n");
  771.       Banner("  EF0.n     = End subset nn percent into sequence\n");
  772.       Banner("  KC        = Calculate clock value for cyclic animation\n");
  773.       Banner("\n");
  774.       Banner("  UF        = use field rendering\n");
  775.       Banner("  UO        = use odd lines in odd frames\n");
  776.  
  777.       break;
  778.  
  779.     /* Redirecting options. */
  780.  
  781.     case 7:
  782.  
  783.       Banner("\n");
  784.       Banner("Redirecting options\n");
  785.       Banner("\n");
  786.       Banner("  GI<name>= write all .INI parameters to file name\n");
  787.       Banner("  Gx<name>= write stream x to console and/or file name\n");
  788.       Banner("            GA - All streams (except status)\n");
  789.       Banner("            GD - Debug stream\n");
  790.       Banner("            GF - Fatal stream\n");
  791.       Banner("            GR - Render stream\n");
  792.       Banner("            GS - Statistics stream\n");
  793.       Banner("            GW - Warning stream\n");
  794.  
  795.       break;
  796.  
  797.     /* Usage ... */
  798.  
  799.     default:
  800.  
  801.       Print_Authors();
  802.   }
  803.  
  804. #if defined(WAIT_FOR_KEYPRESS_EXISTS) && !defined(GET_KEY_EXISTS)
  805.   Banner("\n");
  806.   Banner("[ Paused for keypress... ]");
  807.  
  808.   WAIT_FOR_KEYPRESS;
  809.  
  810.   Banner("\n");
  811. #endif
  812.  
  813.   if (f)
  814.   {
  815.     Terminate_POV(0);
  816.   }
  817. }
  818.  
  819.  
  820. void Print_Authors()
  821. {
  822.   int h, i, j;
  823.  
  824.   Banner("\n");
  825.   Banner("POV-Ray is based on DKBTrace 2.12 by David K. Buck & Aaron A. Collins.\n");
  826.   Banner("\n");
  827.   Banner("Primary POV-Ray 3 Developers: (Alphabetically)\n");
  828.  
  829.   for (i = h = 0; Primary_Developers[h] != NULL; i++)
  830.   {
  831.     for (j = 0; (j < NUMBER_OF_AUTHORS_ACROSS) && (Primary_Developers[h] != NULL); j++)
  832.     {
  833.         Banner(" %-18s", Primary_Developers[h++]);
  834.     }
  835.  
  836.     Banner("\n");
  837.   }
  838.  
  839.   Banner("\n");
  840.   Banner("Major Contributing Authors: (Alphabetically)\n");
  841.  
  842.   for (i = h = 0; Contributing_Authors[h] != NULL; i++)
  843.   {
  844.     for (j = 0; (j < NUMBER_OF_AUTHORS_ACROSS) && (Contributing_Authors[h] != NULL); j++)
  845.     {
  846.         Banner(" %-18s", Contributing_Authors[h++]);
  847.     }
  848.  
  849.     Banner("\n");
  850.   }
  851.  
  852.   Banner("\n");
  853.   Banner("Other contributors listed in the documentation.\n");
  854. }
  855.  
  856.  
  857. /*****************************************************************************
  858. *
  859. * FUNCTION
  860. *
  861. *   Print_Options
  862. *
  863. * INPUT
  864. *   
  865. * OUTPUT
  866. *   
  867. * RETURNS
  868. *   
  869. * AUTHOR
  870. *
  871. *   POV-Ray Team
  872. *   
  873. * DESCRIPTION
  874. *
  875. *   -
  876. *
  877. * CHANGES
  878. *
  879. *   -
  880. *
  881. ******************************************************************************/
  882.  
  883. void Print_Options()
  884. {
  885.   int i, j;
  886.  
  887.   /* Print parsing options. */
  888.  
  889.   Render_Info("Parsing Options\n");
  890.  
  891.   Render_Info("  Input file: %s", strcmp(opts.Input_File_Name, "-") ?
  892.                     opts.Input_File_Name : "stdin");
  893.   Render_Info(" (compatible to version %.1f)\n", opts.Language_Version);
  894.  
  895.   rinfo_on   ("  Remove bounds.......", (opts.Options & REMOVE_BOUNDS));
  896.   rinfo_on   ("  Split unions........", (opts.Options & SPLIT_UNION));
  897.   Render_Info("\n");
  898.  
  899.   j = 17;
  900.  
  901.   Render_Info("  Library paths:");
  902.  
  903.   for (i = 0; i < opts.Library_Path_Index; i++)
  904.   {
  905.     j += strlen(opts.Library_Paths[i])+2;
  906.  
  907.     if (j > 77)
  908.     {
  909.       Render_Info("\n   ", j);
  910.  
  911.       j = strlen(opts.Library_Paths[i]) + 5;
  912.     }
  913.  
  914.     Render_Info(" %s", opts.Library_Paths[i]);
  915.   }
  916.  
  917.   Render_Info("\n");
  918.  
  919.   /* Print output options. */
  920.  
  921.   Render_Info("Output Options\n");
  922.  
  923.   Render_Info("  Image resolution %d by %d",
  924.                                     Frame.Screen_Width, Frame.Screen_Height);
  925.   Render_Info(" (rows %d to %d, columns %d to %d).\n",
  926.                        opts.First_Line+1, opts.Last_Line,
  927.                        opts.First_Column+1, opts.Last_Column);
  928.  
  929.   if (opts.Options & DISKWRITE)
  930.   {
  931.     Render_Info("  Output file: %s%s, ", opts.Output_Path,strcmp(opts.Output_File_Name, "-") ? opts.Output_File_Name : "stdout");
  932.  
  933.     if (toupper(opts.OutputFormat) == 'N' && opts.Options & HF_GRAY_16)
  934.     {
  935.        Render_Info("%d bpp ", opts.OutputQuality);
  936.     }
  937.     else
  938.     {
  939.       Render_Info("%d bpp ", ((opts.Options & OUTPUT_ALPHA) ? 4 : 3) * opts.OutputQuality);
  940.     }
  941.  
  942.     switch (toupper(opts.OutputFormat))
  943.     {
  944.       case 'C': Render_Info("RLE Targa");       break;
  945.       case 'N': Render_Info("PNG");             break;
  946.       case 'P': Render_Info("PPM");             break;
  947.       case 'S': Render_Info("(system format)"); break;
  948.       case 'T': Render_Info("Targa");           break;
  949.     }
  950.  
  951.     if (opts.Options & HF_GRAY_16)
  952.     {
  953.       if (toupper(opts.OutputFormat) == 'N')
  954.       {
  955.         Render_Info(" grayscale");
  956.       }
  957.       else if (opts.Options & HF_GRAY_16)
  958.       {
  959.         Render_Info(" POV heightfield");
  960.       }
  961.     }
  962.  
  963.     if (opts.Options & OUTPUT_ALPHA)
  964.     {
  965.       Render_Info(" with alpha");
  966.     }
  967.  
  968.     if ((opts.Options & BUFFERED_OUTPUT) && (opts.File_Buffer_Size != 0))
  969.     {
  970.       Render_Info(", %d KByte buffer\n", opts.File_Buffer_Size/1024);
  971.     }
  972.     else
  973.     {
  974.       Render_Info("\n");
  975.     }
  976.   }
  977.   else if (opts.Options & DISPLAY)
  978.   {
  979.     if (opts.histogram_on == TRUE)
  980.     {
  981.       Warning(0.0, "  Rendering to screen and histogram file only.\n");
  982.     }
  983.     else
  984.     {
  985.       Warning(0.0, "  Rendering to screen only. No file output.\n");
  986.     }
  987.   }
  988.   else if (opts.histogram_on == TRUE)
  989.   {
  990.     Warning(0.0, "  Rendering to histogram file only.\n");
  991.   }
  992.   else
  993.   {
  994.     Warning(0.0, "  Rendering to nothing! No screen or file output.\n");
  995.   }
  996.  
  997.   rinfo_on   ("  Graphic display.....", (opts.Options & DISPLAY));
  998.   if (opts.Options & DISPLAY)
  999.   {
  1000.     Render_Info("  (type: %c, palette: %c, gamma: %4.2g)",
  1001.                toupper(opts.DisplayFormat), toupper(opts.PaletteOption),
  1002.                opts.DisplayGamma);
  1003.   }
  1004.   Render_Info("\n");
  1005.  
  1006.   rinfo_on   ("  Mosaic preview......", (opts.Options & PREVIEW));
  1007.   if (opts.Options & PREVIEW)
  1008.   {
  1009.     Render_Info("  (pixel sizes %d to %d)",
  1010.                opts.PreviewGridSize_Start, opts.PreviewGridSize_End);
  1011.   }
  1012.   Render_Info("\n");
  1013.  
  1014. #if PRECISION_TIMER_AVAILABLE
  1015.   rinfo_on ("  CPU usage histogram.", opts.histogram_on);
  1016.   if (opts.histogram_on)
  1017.   {
  1018.     char *type;
  1019.  
  1020.     switch (opts.histogram_type)
  1021.     {
  1022.       case CSV:   type = "CSV"; break;
  1023.       case TARGA: type = "TGA"; break;
  1024.       case PNG:   type = "PNG"; break;
  1025.       case PPM:   type = "PPM"; break;
  1026.       case SYS:   type = "(system format)"; break;
  1027.       case NONE:                     /* Just to stop warning messages */
  1028.       default:    type = "None"; break;
  1029.     }
  1030.  
  1031.     Render_Info("  (name: %s type: %s, grid: %dx%d)",
  1032.              opts.Histogram_File_Name,type,opts.histogram_x,opts.histogram_y);
  1033.   }
  1034.   Render_Info("\n");
  1035. #endif /* PRECISION_TIMER_AVAILABLE */
  1036.  
  1037.   rinfo_on   ("  Continued trace.....", (opts.Options & CONTINUE_TRACE));
  1038.   rinfo_on   ("  Allow interruption..", (opts.Options & EXITENABLE));
  1039.   rinfo_on   ("  Pause when done.....", (opts.Options & PROMPTEXIT));
  1040.   Render_Info("\n");
  1041.  
  1042.   rinfo_on   ("  Verbose messages....", (opts.Options & VERBOSE));
  1043.  
  1044.   Render_Info("\n");
  1045.  
  1046.   /* Print tracing options. */
  1047.  
  1048.   Render_Info("Tracing Options\n");
  1049.  
  1050.   Render_Info("  Quality: %2d\n", opts.Quality);
  1051.  
  1052.   rinfo_on   ("  Bounding boxes......", opts.Use_Slabs);
  1053.   if (opts.Use_Slabs)
  1054.   {
  1055.     Render_Info("  Bounding threshold: %d ", opts.BBox_Threshold);
  1056.   }
  1057.   Render_Info("\n");
  1058.  
  1059.   rinfo_on("  Light Buffer........", (opts.Options & USE_LIGHT_BUFFER));
  1060.   rinfo_on("  Vista Buffer........", (opts.Options & USE_VISTA_BUFFER));
  1061.   if (opts.Options & USE_VISTA_BUFFER && opts.Options & DISPLAY)
  1062.   {
  1063.     rinfo_on("  Draw Vista Buffer...", (opts.Options & USE_VISTA_DRAW));
  1064.   }
  1065.   Render_Info("\n");
  1066.  
  1067.   rinfo_on   ("  Antialiasing........", (opts.Options & ANTIALIAS));
  1068.   if (opts.Options & ANTIALIAS)
  1069.   {
  1070.     Render_Info("  (Method %d, ", opts.Tracing_Method);
  1071.     Render_Info("Threshold %.3f, ", opts.Antialias_Threshold);
  1072.     Render_Info("Depth %ld, ", opts.AntialiasDepth);
  1073.     Render_Info("Jitter %.2f)", opts.JitterScale);
  1074.   }
  1075.   Render_Info("\n");
  1076.  
  1077.   rinfo_on   ("  Radiosity...........", (opts.Options & RADIOSITY));
  1078.  
  1079.   Render_Info("\n");
  1080.  
  1081.   /* Print animation options. */
  1082.  
  1083.   Render_Info("Animation Options\n");
  1084.  
  1085.   if (opts.FrameSeq.FrameType == FT_MULTIPLE_FRAME)
  1086.   {
  1087.     Render_Info("  Initial Frame..%8d", opts.FrameSeq.InitialFrame);
  1088.     Render_Info("  Final Frame....%8d\n", opts.FrameSeq.FinalFrame);
  1089.     Render_Info("  Initial Clock..%8.3f", opts.FrameSeq.InitialClock);
  1090.     Render_Info("  Final Clock....%8.3f\n", opts.FrameSeq.FinalClock);
  1091.     rinfo_on   ("  Cyclic Animation....", (opts.Options & CYCLIC_ANIMATION));
  1092.     rinfo_on   ("  Field render........", (opts.FrameSeq.Field_Render_Flag));
  1093.     rinfo_on   ("  Odd lines/frames....", (opts.FrameSeq.Odd_Field_Flag));
  1094.   }
  1095.   else
  1096.   {
  1097.     Render_Info("  Clock value....%8.3f", opts.FrameSeq.Clock_Value);
  1098.     Render_Info("  (Animation off)");
  1099.   }
  1100.  
  1101.   Render_Info("\n");
  1102.  
  1103.   /* Print redirecting options. */
  1104.  
  1105.   Render_Info("Redirecting Options\n");
  1106.  
  1107.   rinfo_on   ("  All Streams to console.........", Stream_Info[ALL_STREAM].do_console);
  1108.   if (Stream_Info[ALL_STREAM].name == NULL)
  1109.   {
  1110.     Render_Info("\n");
  1111.   }
  1112.   else
  1113.   {
  1114.     Render_Info("  and file %s\n", Stream_Info[ALL_STREAM].name);
  1115.   }
  1116.  
  1117.   rinfo_on   ("  Debug Stream to console........", Stream_Info[DEBUG_STREAM].do_console);
  1118.   if (Stream_Info[DEBUG_STREAM].name == NULL)
  1119.   {
  1120.     Render_Info("\n");
  1121.   }
  1122.   else
  1123.   {
  1124.     Render_Info("  and file %s\n", Stream_Info[DEBUG_STREAM].name);
  1125.   }
  1126.  
  1127.   rinfo_on   ("  Fatal Stream to console........", Stream_Info[FATAL_STREAM].do_console);
  1128.   if (Stream_Info[FATAL_STREAM].name == NULL)
  1129.   {
  1130.     Render_Info("\n");
  1131.   }
  1132.   else
  1133.   {
  1134.     Render_Info("  and file %s\n", Stream_Info[FATAL_STREAM].name);
  1135.   }
  1136.  
  1137.   rinfo_on   ("  Render Stream to console.......", Stream_Info[RENDER_STREAM].do_console);
  1138.   if (Stream_Info[RENDER_STREAM].name == NULL)
  1139.   {
  1140.     Render_Info("\n");
  1141.   }
  1142.   else
  1143.   {
  1144.     Render_Info("  and file %s\n", Stream_Info[RENDER_STREAM].name);
  1145.   }
  1146.  
  1147.   rinfo_on   ("  Statistics Stream to console...", Stream_Info[STATISTIC_STREAM].do_console);
  1148.   if (Stream_Info[STATISTIC_STREAM].name == NULL)
  1149.   {
  1150.     Render_Info("\n");
  1151.   }
  1152.   else
  1153.   {
  1154.     Render_Info("  and file %s\n", Stream_Info[STATISTIC_STREAM].name);
  1155.   }
  1156.  
  1157.   rinfo_on   ("  Warning Stream to console......", Stream_Info[WARNING_STREAM].do_console);
  1158.   if (Stream_Info[WARNING_STREAM].name == NULL)
  1159.   {
  1160.     Render_Info("\n");
  1161.   }
  1162.   else
  1163.   {
  1164.     Render_Info("  and file %s\n", Stream_Info[WARNING_STREAM].name);
  1165.   }
  1166. }
  1167.  
  1168.  
  1169.  
  1170. /*****************************************************************************
  1171. *
  1172. * FUNCTION
  1173. *
  1174. *   Print_Stats
  1175. *
  1176. * INPUT
  1177. *   
  1178. * OUTPUT
  1179. *   
  1180. * RETURNS
  1181. *   
  1182. * AUTHOR
  1183. *
  1184. *   POV-Ray Team
  1185. *
  1186. * DESCRIPTION
  1187. *
  1188. *   -
  1189. *
  1190. * CHANGES
  1191. *
  1192. *   -
  1193. *
  1194. ******************************************************************************/
  1195.  
  1196. void Print_Stats(pstats)
  1197.   COUNTER *pstats;
  1198. {
  1199.   unsigned long hours, minutes;
  1200.   DBL seconds, taverage, ttotal;
  1201.   long Pixels_In_Image;
  1202.  
  1203.   Pixels_In_Image = (long)Frame.Screen_Width * (long)Frame.Screen_Height;
  1204.  
  1205.   Statistics ("\n%s Statistics", opts.Input_File_Name);
  1206.  
  1207.   if ( Pixels_In_Image > DBL_Counter(pstats[Number_Of_Pixels]) )
  1208.     Statistics (" (Partial Image Rendered)");
  1209.  
  1210.   Statistics (", Resolution %d x %d\n", Frame.Screen_Width, Frame.Screen_Height);
  1211.  
  1212.   Statistics ("----------------------------------------------------------------------------\n");
  1213.  
  1214.   Statistics ("Pixels: %15.0f   Samples: %15.0f   Smpls/Pxl: ",
  1215.               DBL_Counter(pstats[Number_Of_Pixels]),
  1216.               DBL_Counter(pstats[Number_Of_Samples]));
  1217.  
  1218.   if (!Test_Zero_Counter(pstats[Number_Of_Pixels]))
  1219.   {
  1220.     Statistics ("%.2f\n",
  1221.               DBL_Counter(pstats[Number_Of_Samples]) /
  1222.               DBL_Counter(pstats[Number_Of_Pixels]));
  1223.   }
  1224.   else
  1225.   {
  1226.     Statistics ("-\n");
  1227.   }
  1228.  
  1229.   counter_to_string(&pstats[Number_Of_Rays], s1, OUTPUT_LENGTH);
  1230.   counter_to_string(&pstats[ADC_Saves], s2, OUTPUT_LENGTH);
  1231.  
  1232.   Statistics ("Rays:    %s   Saved:    %s   Max Level: %d/%d\n",
  1233.               s1, s2, Highest_Trace_Level, Max_Trace_Level);
  1234.  
  1235.   Statistics ("----------------------------------------------------------------------------\n");
  1236.  
  1237.   Statistics ("Ray->Shape Intersection          Tests       Succeeded  Percentage\n");
  1238.   Statistics ("----------------------------------------------------------------------------\n");
  1239.  
  1240.   print_intersection_stats("Bezier Patch",          &pstats[Ray_Bicubic_Tests],
  1241.        &pstats[Ray_Bicubic_Tests_Succeeded]);
  1242.  
  1243.   print_intersection_stats("Blob",                  &pstats[Ray_Blob_Tests],
  1244.        &pstats[Ray_Blob_Tests_Succeeded]);
  1245. #ifdef BLOB_EXTRA_STATS
  1246.   print_intersection_stats("Blob Component",        &pstats[Blob_Element_Tests],
  1247.        &pstats[Blob_Element_Tests_Succeeded]);
  1248.   print_intersection_stats("Blob Bound",            &pstats[Blob_Bound_Tests],
  1249.        &pstats[Blob_Bound_Tests_Succeeded]);
  1250. #endif
  1251.  
  1252.   print_intersection_stats("Box",                   &pstats[Ray_Box_Tests],
  1253.        &pstats[Ray_Box_Tests_Succeeded]);
  1254.   print_intersection_stats("Cone/Cylinder",         &pstats[Ray_Cone_Tests],
  1255.        &pstats[Ray_Cone_Tests_Succeeded]);
  1256.   print_intersection_stats("CSG Intersection",      &pstats[Ray_CSG_Intersection_Tests],
  1257.        &pstats[Ray_CSG_Intersection_Tests_Succeeded]);
  1258.   print_intersection_stats("CSG Merge",             &pstats[Ray_CSG_Merge_Tests],
  1259.        &pstats[Ray_CSG_Merge_Tests_Succeeded]);
  1260.   print_intersection_stats("CSG Union",             &pstats[Ray_CSG_Union_Tests],
  1261.        &pstats[Ray_CSG_Union_Tests_Succeeded]);
  1262.   print_intersection_stats("Disc",                  &pstats[Ray_Disc_Tests],
  1263.        &pstats[Ray_Disc_Tests_Succeeded]);
  1264.   print_intersection_stats("Fractal",               &pstats[Ray_Fractal_Tests],
  1265.        &pstats[Ray_Fractal_Tests_Succeeded]);
  1266.  
  1267.   print_intersection_stats("Height Field",          &pstats[Ray_HField_Tests],
  1268.        &pstats[Ray_HField_Tests_Succeeded]);
  1269. #ifdef HFIELD_EXTRA_STATS
  1270.   print_intersection_stats("Height Field Box",      &pstats[Ray_HField_Box_Tests],
  1271.        &pstats[Ray_HField_Box_Tests_Succeeded]);
  1272.   print_intersection_stats("Height Field Triangle", &pstats[Ray_HField_Triangle_Tests],
  1273.        &pstats[Ray_HField_Triangle_Tests_Succeeded]);
  1274.   print_intersection_stats("Height Field Block",    &pstats[Ray_HField_Block_Tests],
  1275.        &pstats[Ray_HField_Block_Tests_Succeeded]);
  1276.   print_intersection_stats("Height Field Cell",     &pstats[Ray_HField_Cell_Tests],
  1277.        &pstats[Ray_HField_Cell_Tests_Succeeded]);
  1278. #endif
  1279.  
  1280.   print_intersection_stats("Lathe",                 &pstats[Ray_Lathe_Tests],
  1281.        &pstats[Ray_Lathe_Tests_Succeeded]);
  1282. #ifdef LATHE_EXTRA_STATS
  1283.   print_intersection_stats("Lathe Bound",           &pstats[Lathe_Bound_Tests],
  1284.        &pstats[Lathe_Bound_Tests_Succeeded]);
  1285. #endif
  1286.  
  1287.   print_intersection_stats("Mesh",                  &pstats[Ray_Mesh_Tests],
  1288.        &pstats[Ray_Mesh_Tests_Succeeded]);
  1289.   print_intersection_stats("Plane",                 &pstats[Ray_Plane_Tests],
  1290.        &pstats[Ray_Plane_Tests_Succeeded]);
  1291.   print_intersection_stats("Polygon",               &pstats[Ray_Polygon_Tests],
  1292.        &pstats[Ray_Polygon_Tests_Succeeded]);
  1293.  
  1294.   print_intersection_stats("Prism",                 &pstats[Ray_Prism_Tests],
  1295.        &pstats[Ray_Prism_Tests_Succeeded]);
  1296. #ifdef PRISM_EXTRA_STATS
  1297.   print_intersection_stats("Prism Bound",           &pstats[Prism_Bound_Tests],
  1298.        &pstats[Prism_Bound_Tests_Succeeded]);
  1299. #endif
  1300.  
  1301.   print_intersection_stats("Quadric",               &pstats[Ray_Quadric_Tests],
  1302.        &pstats[Ray_Quadric_Tests_Succeeded]);
  1303.   print_intersection_stats("Quartic/Poly",          &pstats[Ray_Poly_Tests],
  1304.        &pstats[Ray_Poly_Tests_Succeeded]);
  1305.   print_intersection_stats("Sphere",                &pstats[Ray_Sphere_Tests],
  1306.        &pstats[Ray_Sphere_Tests_Succeeded]);
  1307.   print_intersection_stats("Superellipsoid",        &pstats[Ray_Superellipsoid_Tests],
  1308.        &pstats[Ray_Superellipsoid_Tests_Succeeded]);
  1309.  
  1310.   print_intersection_stats("Surface of Revolution", &pstats[Ray_Sor_Tests],
  1311.        &pstats[Ray_Sor_Tests_Succeeded]);
  1312. #ifdef SOR_EXTRA_STATS
  1313.   print_intersection_stats("Surface of Rev. Bound", &pstats[Sor_Bound_Tests],
  1314.        &pstats[Sor_Bound_Tests_Succeeded]);
  1315. #endif
  1316.  
  1317.   print_intersection_stats("Torus",                 &pstats[Ray_Torus_Tests],
  1318.        &pstats[Ray_Torus_Tests_Succeeded]);
  1319. #ifdef TORUS_EXTRA_STATS
  1320.   print_intersection_stats("Torus Bound",           &pstats[Torus_Bound_Tests],
  1321.        &pstats[Torus_Bound_Tests_Succeeded]);
  1322. #endif
  1323.  
  1324.   print_intersection_stats("Triangle",              &pstats[Ray_Triangle_Tests],
  1325.        &pstats[Ray_Triangle_Tests_Succeeded]);
  1326.   print_intersection_stats("True Type Font",        &pstats[Ray_TTF_Tests],
  1327.        &pstats[Ray_TTF_Tests_Succeeded]);
  1328.  
  1329.   print_intersection_stats("Bounding Object", &pstats[Bounding_Region_Tests],
  1330.        &pstats[Bounding_Region_Tests_Succeeded]);
  1331.   print_intersection_stats("Clipping Object", &pstats[Clipping_Region_Tests],
  1332.        &pstats[Clipping_Region_Tests_Succeeded]);
  1333.   print_intersection_stats("Bounding Box",    &pstats[nChecked],
  1334.        &pstats[nEnqueued]);
  1335.   print_intersection_stats("Light Buffer",    &pstats[LBuffer_Tests],
  1336.        &pstats[LBuffer_Tests_Succeeded]);
  1337.   print_intersection_stats("Vista Buffer",    &pstats[VBuffer_Tests],
  1338.        &pstats[VBuffer_Tests_Succeeded]);
  1339.  
  1340.   Statistics ("----------------------------------------------------------------------------\n");
  1341.  
  1342.   if (!Test_Zero_Counter(pstats[Polynomials_Tested]))
  1343.   {
  1344.     counter_to_string(&pstats[Polynomials_Tested], s1, OUTPUT_LENGTH);
  1345.     counter_to_string(&pstats[Roots_Eliminated], s2, OUTPUT_LENGTH);
  1346.  
  1347.     Statistics ("Roots tested:       %s   eliminated:      %s\n", s1, s2);
  1348.   }
  1349.  
  1350.   counter_to_string(&pstats[Calls_To_Noise], s1, OUTPUT_LENGTH);
  1351.   counter_to_string(&pstats[Calls_To_DNoise], s2, OUTPUT_LENGTH);
  1352.  
  1353.   Statistics ("Calls to Noise:     %s   Calls to DNoise: %s\n", s1, s2);
  1354.  
  1355.   Statistics ("----------------------------------------------------------------------------\n");
  1356.  
  1357.   /* Print halo samples. */
  1358.  
  1359.   if (!Test_Zero_Counter(pstats[Halo_Rays_Traced]))
  1360.   {
  1361.     counter_to_string(&pstats[Halo_Samples], s1, OUTPUT_LENGTH);
  1362.     counter_to_string(&pstats[Halo_Supersamples], s2, OUTPUT_LENGTH);
  1363.  
  1364.     Statistics ("Halo Samples:       %s   Supersamples:    %s\n", s1, s2);
  1365.   }
  1366.  
  1367.   /* Print atmosphere samples. */
  1368.  
  1369.   if (!Test_Zero_Counter(pstats[Atmosphere_Samples]))
  1370.   {
  1371.     counter_to_string(&pstats[Atmosphere_Samples], s1, OUTPUT_LENGTH);
  1372.     counter_to_string(&pstats[Atmosphere_Supersamples], s2, OUTPUT_LENGTH);
  1373.  
  1374.     Statistics ("Atmosphere Samples: %s   Supersamples:    %s\n", s1, s2);
  1375.   }
  1376.  
  1377.   if (!Test_Zero_Counter(pstats[Shadow_Ray_Tests]))
  1378.   {
  1379.     counter_to_string(&pstats[Shadow_Ray_Tests], s1, OUTPUT_LENGTH);
  1380.     counter_to_string(&pstats[Shadow_Rays_Succeeded], s2, OUTPUT_LENGTH);
  1381.  
  1382.     Statistics ("Shadow Ray Tests:   %s   Succeeded:       %s\n", s1, s2);
  1383.   }
  1384.  
  1385.   if (!Test_Zero_Counter(pstats[Reflected_Rays_Traced]))
  1386.   {
  1387.     counter_to_string(&pstats[Reflected_Rays_Traced], s1, OUTPUT_LENGTH);
  1388.  
  1389.     Statistics ("Reflected Rays:     %s\n", s1);
  1390.   }
  1391.  
  1392.   if (!Test_Zero_Counter(pstats[Refracted_Rays_Traced]))
  1393.   {
  1394.     counter_to_string(&pstats[Refracted_Rays_Traced], s1, OUTPUT_LENGTH);
  1395.  
  1396.     Statistics ("Refracted Rays:     %s\n", s1);
  1397.   }
  1398.  
  1399.   if (!Test_Zero_Counter(pstats[Transmitted_Rays_Traced]))
  1400.   {
  1401.     counter_to_string(&pstats[Transmitted_Rays_Traced], s1, OUTPUT_LENGTH);
  1402.  
  1403.     Statistics ("Transmitted Rays:   %s\n", s1);
  1404.   }
  1405.  
  1406.   if (!Test_Zero_Counter(pstats[Istack_overflows]))
  1407.   {
  1408.     counter_to_string(&pstats[Istack_overflows], s1, OUTPUT_LENGTH);
  1409.  
  1410.     Statistics ("I-Stack overflows:  %s\n", s1);
  1411.   }
  1412.  
  1413.   if ( ra_reuse_count || ra_gather_count )
  1414.   {
  1415.     Statistics ("----------------------------------------------------------------------------\n");
  1416.     Statistics ("Radiosity samples calculated:  %9ld (%.2f percent)\n", ra_gather_count,
  1417.                 100.*(DBL) ra_gather_count / ((DBL)(ra_gather_count + ra_reuse_count)));
  1418.     /* Note:  don't try to put in a percent sign.  There is basically no way to do this
  1419.        which is completely portable using va_start */
  1420.     Statistics ("Radiosity samples reused:      %9ld\n", ra_reuse_count);
  1421.   }
  1422.  
  1423. #if defined(MEM_STATS)
  1424.   Statistics ("----------------------------------------------------------------------------\n");
  1425.  
  1426.   Long_To_Counter(mem_stats_smallest_alloc(), pstats[MemStat_Smallest_Alloc]);
  1427.   counter_to_string(&pstats[MemStat_Smallest_Alloc], s1, OUTPUT_LENGTH);
  1428.  
  1429.   Long_To_Counter(mem_stats_largest_alloc(), pstats[MemStat_Largest_Alloc]);
  1430.   counter_to_string(&pstats[MemStat_Largest_Alloc],  s2, OUTPUT_LENGTH);
  1431.  
  1432. #if (MEM_STATS==1)
  1433.   Statistics ("Smallest Alloc:     %s bytes   Largest:   %s\n", s1, s2);
  1434. #elif (MEM_STATS>=2)
  1435.   Statistics ("Smallest Alloc:     %s bytes @ %s:%d\n", s1, mem_stats_smallest_file(), mem_stats_smallest_line());
  1436.   Statistics ("Largest  Alloc:     %s bytes @ %s:%d\n", s2, mem_stats_largest_file(), mem_stats_largest_line());
  1437.  
  1438.   Long_To_Counter(mem_stats_total_allocs(), pstats[MemStat_Total_Allocs]);
  1439.   counter_to_string(&pstats[MemStat_Total_Allocs], s1, OUTPUT_LENGTH);
  1440.   Long_To_Counter(mem_stats_total_frees(), pstats[MemStat_Total_Frees]);
  1441.   counter_to_string(&pstats[MemStat_Total_Frees], s2, OUTPUT_LENGTH);
  1442.   Statistics ("Total Alloc calls:  %s         Free calls:%s\n", s1, s2);
  1443. #endif
  1444.  
  1445.   Long_To_Counter(mem_stats_largest_mem_usage(), pstats[MemStat_Largest_Mem_Usage]);
  1446.   counter_to_string(&pstats[MemStat_Largest_Mem_Usage], s1, OUTPUT_LENGTH);
  1447.   Statistics ("Peak memory used:   %s bytes\n", s1);
  1448.  
  1449. #endif
  1450.  
  1451.   Statistics ("----------------------------------------------------------------------------\n");
  1452.  
  1453.   /* Get time in case the trace was aborted. */
  1454.  
  1455.   if (trender == 0.0)
  1456.   {
  1457.     STOP_TIME
  1458.  
  1459.     trender = TIME_ELAPSED
  1460.     trender /= 200.0;
  1461.   }
  1462.  
  1463.   if (opts.FrameSeq.FrameType == FT_MULTIPLE_FRAME)
  1464.   {
  1465.     if (tparse_total != 0.0)
  1466.     {
  1467.       taverage = tparse_total /
  1468.           (DBL)(opts.FrameSeq.FrameNumber - opts.FrameSeq.InitialFrame + 1);
  1469.  
  1470.       SPLIT_TIME(taverage,&hours,&minutes,&seconds);
  1471. /*
  1472.       Statistics ("Time For Parse/Frame:  %3ld hours %2ld minutes %5.1f seconds (%ld seconds)\n",
  1473.           hours, minutes, seconds, (long)taverage);
  1474. */
  1475.       Statistics ("Time For Parse/Frame:  %3ld hours %2ld minutes %5.2f seconds (%8.2f seconds)\n",
  1476.           hours, minutes, seconds, taverage);
  1477.  
  1478.       SPLIT_TIME(tparse_total,&hours,&minutes,&seconds);
  1479. /*
  1480.       Statistics ("Time For Parse Total:  %3ld hours %2ld minutes %5.1f seconds (%ld seconds)\n",
  1481.           hours, minutes, seconds, (long)tparse_total);
  1482. */
  1483.       Statistics ("Time For Parse Total:  %3ld hours %2ld minutes %5.2f seconds (%8.2f seconds)\n",
  1484.           hours, minutes, seconds, tparse_total);
  1485.     }
  1486.  
  1487.     if (trender_total != 0.0)
  1488.     {
  1489.       taverage = trender_total /
  1490.           (DBL)(opts.FrameSeq.FrameNumber - opts.FrameSeq.InitialFrame + 1);
  1491.  
  1492.       SPLIT_TIME(taverage,&hours,&minutes,&seconds);
  1493. /*
  1494.       Statistics ("Time For Trace/Frame:  %3ld hours %2ld minutes %5.1f seconds (%ld seconds)\n",
  1495.           hours, minutes, seconds, (long)taverage);
  1496. */
  1497.       Statistics ("Time For Trace/Frame:  %3ld hours %2ld minutes %5.2f seconds (%8.2f seconds)\n",
  1498.           hours, minutes, seconds, taverage);
  1499.  
  1500.       SPLIT_TIME(trender_total,&hours,&minutes,&seconds);
  1501. /*
  1502.       Statistics ("Time For Trace Total:  %3ld hours %2ld minutes %5.1f seconds (%ld seconds)\n",
  1503.           hours, minutes, seconds, (long)trender_total);
  1504. */
  1505.       Statistics ("Time For Trace Total:  %3ld hours %2ld minutes %5.2f seconds (%8.2f seconds)\n",
  1506.           hours, minutes, seconds, trender_total);
  1507.     }
  1508.  
  1509.     ttotal = tparse_total + trender_total;
  1510.  
  1511.     if (ttotal != 0.0)
  1512.     {
  1513.       SPLIT_TIME(ttotal,&hours,&minutes,&seconds);
  1514. /*
  1515.       Statistics ("          Total Time:  %3ld hours %2ld minutes %5.1f seconds (%ld seconds)\n",
  1516.           hours, minutes, seconds, (long)ttotal);
  1517. */
  1518.       Statistics ("          Total Time:  %3ld hours %2ld minutes %5.2f seconds (%8.2f seconds)\n",
  1519.           hours, minutes, seconds, ttotal);
  1520.     }
  1521.   }
  1522.   else
  1523.   {
  1524.     if (tparse != 0.0)
  1525.     {
  1526.       SPLIT_TIME(tparse,&hours,&minutes,&seconds);
  1527. /*
  1528.       Statistics ("Time For Parse:  %3ld hours %2ld minutes %5.1f seconds (%ld seconds)\n",
  1529.           hours, minutes, seconds, (long)tparse);
  1530. */
  1531.       Statistics ("Time For Parse:  %3ld hours %2ld minutes %5.2f seconds (%8.2f seconds)\n",
  1532.           hours, minutes, seconds, tparse);
  1533.     }
  1534.  
  1535.     if (trender != 0.0)
  1536.     {
  1537.       SPLIT_TIME(trender,&hours,&minutes,&seconds);
  1538. /*
  1539.       Statistics ("Time For Trace:  %3ld hours %2ld minutes %5.1f seconds (%ld seconds)\n",
  1540.           hours, minutes, seconds, (long)trender);
  1541. */
  1542.       Statistics ("Time For Trace:  %3ld hours %2ld minutes %5.2f seconds (%8.2f seconds)\n",
  1543.           hours, minutes, seconds, trender);
  1544.     }
  1545.  
  1546.     ttotal = tparse + trender;
  1547.  
  1548.     if (ttotal != 0.0)
  1549.     {
  1550.       SPLIT_TIME(ttotal,&hours,&minutes,&seconds);
  1551. /*
  1552.       Statistics ("    Total Time:  %3ld hours %2ld minutes %5.1f seconds (%ld seconds)\n",
  1553.           hours, minutes, seconds, (long)ttotal);
  1554. */
  1555.       Statistics ("    Total Time:  %3ld hours %2ld minutes %5.2f seconds (%8.2f seconds)\n",
  1556.           hours, minutes, seconds, ttotal);
  1557.     }
  1558.   }
  1559. }
  1560.